/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JFPrincipal.java
 *
 * Created on 25/07/2011, 09:01:07
 */
package apresentacao;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.beans.PropertyVetoException;
import java.text.Normalizer.Form;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

/**
 *
 * @author Felipe
 */
public class JFPrincipal extends JFrame {
    private JIFUsuario formUsuario;    

    /** Creates new form JFPrincipal */
    public JFPrincipal() {
        initComponents();             
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pnlCentro = new javax.swing.JPanel();
        pnlCentroNorte = new javax.swing.JPanel();
        pnlCentroSul = new javax.swing.JPanel();
        jtbInferior = new javax.swing.JToolBar();
        lblEspaco1 = new javax.swing.JLabel();
        lblUsuario = new javax.swing.JLabel();
        lblDatabasePath = new javax.swing.JLabel();
        lblFrame = new javax.swing.JLabel();
        lblEspaco2 = new javax.swing.JLabel();
        pnlCentroLeste = new javax.swing.JPanel();
        pnlCentroOeste = new javax.swing.JPanel();
        jDesktopPane = new javax.swing.JDesktopPane();
        jtbSuperior = new javax.swing.JToolBar();
        btnChamado = new javax.swing.JButton();
        btnUsuario = new javax.swing.JButton();
        btnPessoaFisica = new javax.swing.JButton();
        btnPessoaJuridica = new javax.swing.JButton();
        btnServico = new javax.swing.JButton();
        btnContas = new javax.swing.JButton();
        btnEstatisticas = new javax.swing.JButton();
        btnCertficado = new javax.swing.JButton();
        btnEmail = new javax.swing.JButton();
        btnHardware = new javax.swing.JButton();
        btnConfiguracoes = new javax.swing.JButton();
        btnSair = new javax.swing.JButton();
        jmbPrincipal = new javax.swing.JMenuBar();
        jmSistema = new javax.swing.JMenu();
        jmiConfiguracoes = new javax.swing.JMenuItem();
        jmiSair = new javax.swing.JMenuItem();
        jmTabelas = new javax.swing.JMenu();
        jmiUsuario = new javax.swing.JMenuItem();
        jmiPessoaFisica = new javax.swing.JMenuItem();
        jmiPessoaJurídica = new javax.swing.JMenuItem();
        jmiCertificado = new javax.swing.JMenuItem();
        jmiEmail = new javax.swing.JMenuItem();
        jmAjuda = new javax.swing.JMenu();
        jmiSobre = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("SIGEPI - Sistema Gestor de Parque de Informática - Ver.: 1.0.0");
        setExtendedState(JFrame.MAXIMIZED_BOTH);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        pnlCentro.setLayout(new java.awt.BorderLayout());
        pnlCentro.add(pnlCentroNorte, java.awt.BorderLayout.PAGE_START);

        pnlCentroSul.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        pnlCentroSul.setLayout(new javax.swing.BoxLayout(pnlCentroSul, javax.swing.BoxLayout.LINE_AXIS));

        jtbInferior.setFloatable(false);
        jtbInferior.setRollover(true);

        lblEspaco1.setText("  ");
        jtbInferior.add(lblEspaco1);

        lblUsuario.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblUsuario.setText("felipe");
        lblUsuario.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
        lblUsuario.setMaximumSize(new java.awt.Dimension(125, 20));
        lblUsuario.setMinimumSize(new java.awt.Dimension(125, 20));
        lblUsuario.setPreferredSize(new java.awt.Dimension(100, 18));
        jtbInferior.add(lblUsuario);

        lblDatabasePath.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblDatabasePath.setText("172.36.5.132\\dados\\base.gdb");
        lblDatabasePath.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
        lblDatabasePath.setMaximumSize(new java.awt.Dimension(450, 20));
        lblDatabasePath.setMinimumSize(new java.awt.Dimension(450, 20));
        lblDatabasePath.setPreferredSize(new java.awt.Dimension(500, 18));
        jtbInferior.add(lblDatabasePath);

        lblFrame.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblFrame.setText("SIGEPI - Sistema gestor de Parque de Informática");
        lblFrame.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
        lblFrame.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        lblFrame.setMaximumSize(getMaximumSize());
        jtbInferior.add(lblFrame);

        lblEspaco2.setText("  ");
        lblEspaco2.setMaximumSize(new java.awt.Dimension(15, 4));
        lblEspaco2.setMinimumSize(new java.awt.Dimension(15, 4));
        jtbInferior.add(lblEspaco2);

        pnlCentroSul.add(jtbInferior);

        pnlCentro.add(pnlCentroSul, java.awt.BorderLayout.PAGE_END);
        pnlCentro.add(pnlCentroLeste, java.awt.BorderLayout.LINE_END);
        pnlCentro.add(pnlCentroOeste, java.awt.BorderLayout.LINE_START);

        jDesktopPane.setBackground(new java.awt.Color(153, 153, 153));
        pnlCentro.add(jDesktopPane, java.awt.BorderLayout.CENTER);

        getContentPane().add(pnlCentro, java.awt.BorderLayout.CENTER);

        jtbSuperior.setRollover(true);

        btnChamado.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/i48x48/atendente3.png"))); // NOI18N
        btnChamado.setToolTipText("Chamado");
        btnChamado.setFocusable(false);
        btnChamado.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnChamado.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jtbSuperior.add(btnChamado);

        btnUsuario.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/i48x48/pessoa.png"))); // NOI18N
        btnUsuario.setToolTipText("Usuario");
        btnUsuario.setFocusable(false);
        btnUsuario.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnUsuario.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnUsuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUsuarioActionPerformed(evt);
            }
        });
        jtbSuperior.add(btnUsuario);

        btnPessoaFisica.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/i48x48/executivo1.png"))); // NOI18N
        btnPessoaFisica.setToolTipText("Pessoa Física");
        btnPessoaFisica.setFocusable(false);
        btnPessoaFisica.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnPessoaFisica.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnPessoaFisica.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPessoaFisicaActionPerformed(evt);
            }
        });
        jtbSuperior.add(btnPessoaFisica);

        btnPessoaJuridica.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/i48x48/empresa1.png"))); // NOI18N
        btnPessoaJuridica.setToolTipText("Pessoa Jurídica");
        btnPessoaJuridica.setFocusable(false);
        btnPessoaJuridica.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnPessoaJuridica.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jtbSuperior.add(btnPessoaJuridica);

        btnServico.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/i48x48/maleta1.png"))); // NOI18N
        btnServico.setToolTipText("Serviço");
        btnServico.setFocusable(false);
        btnServico.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnServico.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jtbSuperior.add(btnServico);

        btnContas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/i48x48/dinheiro4.png"))); // NOI18N
        btnContas.setToolTipText("Contas a pagar");
        btnContas.setFocusable(false);
        btnContas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnContas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jtbSuperior.add(btnContas);

        btnEstatisticas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/i48x48/estatisticas.png"))); // NOI18N
        btnEstatisticas.setToolTipText("Estatísticas");
        btnEstatisticas.setFocusable(false);
        btnEstatisticas.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnEstatisticas.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jtbSuperior.add(btnEstatisticas);

        btnCertficado.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/i48x48/chave.png"))); // NOI18N
        btnCertficado.setToolTipText("Certificado digital");
        btnCertficado.setFocusable(false);
        btnCertficado.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnCertficado.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jtbSuperior.add(btnCertficado);

        btnEmail.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/i48x48/email.png"))); // NOI18N
        btnEmail.setToolTipText("Email");
        btnEmail.setFocusable(false);
        btnEmail.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnEmail.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jtbSuperior.add(btnEmail);

        btnHardware.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/i48x48/hardware.png"))); // NOI18N
        btnHardware.setToolTipText("Hardware");
        btnHardware.setFocusable(false);
        btnHardware.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnHardware.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jtbSuperior.add(btnHardware);

        btnConfiguracoes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/i48x48/configuracoes.png"))); // NOI18N
        btnConfiguracoes.setToolTipText("Configurações");
        btnConfiguracoes.setFocusable(false);
        btnConfiguracoes.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnConfiguracoes.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jtbSuperior.add(btnConfiguracoes);

        btnSair.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/i48x48/sair.png"))); // NOI18N
        btnSair.setToolTipText("Sair");
        btnSair.setFocusable(false);
        btnSair.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnSair.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSairActionPerformed(evt);
            }
        });
        jtbSuperior.add(btnSair);

        getContentPane().add(jtbSuperior, java.awt.BorderLayout.PAGE_START);

        jmSistema.setText("Sistema");

        jmiConfiguracoes.setText("Configurações");
        jmSistema.add(jmiConfiguracoes);

        jmiSair.setText("Sair");
        jmiSair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiSairActionPerformed(evt);
            }
        });
        jmSistema.add(jmiSair);

        jmbPrincipal.add(jmSistema);

        jmTabelas.setText("Tabelas");

        jmiUsuario.setText("Usuario");
        jmiUsuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiUsuarioActionPerformed(evt);
            }
        });
        jmTabelas.add(jmiUsuario);

        jmiPessoaFisica.setText("Pessoa Física");
        jmTabelas.add(jmiPessoaFisica);

        jmiPessoaJurídica.setText("Pessoa Jurídica");
        jmTabelas.add(jmiPessoaJurídica);

        jmiCertificado.setText("Certificado Digital");
        jmTabelas.add(jmiCertificado);

        jmiEmail.setText("Email");
        jmiEmail.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiEmailActionPerformed(evt);
            }
        });
        jmTabelas.add(jmiEmail);

        jmbPrincipal.add(jmTabelas);

        jmAjuda.setText("Ajuda");

        jmiSobre.setText("Sobre");
        jmiSobre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jmiSobreActionPerformed(evt);
            }
        });
        jmAjuda.add(jmiSobre);

        jmbPrincipal.add(jmAjuda);

        setJMenuBar(jmbPrincipal);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-900)/2, (screenSize.height-597)/2, 900, 597);
    }// </editor-fold>//GEN-END:initComponents

    private void btnPessoaFisicaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPessoaFisicaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnPessoaFisicaActionPerformed

    private void jmiSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiSairActionPerformed
        fecharAplicacao();
    }//GEN-LAST:event_jmiSairActionPerformed

    private void btnSairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSairActionPerformed
        fecharAplicacao();
    }//GEN-LAST:event_btnSairActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        fecharAplicacao();
    }//GEN-LAST:event_formWindowClosing

    private void jmiUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiUsuarioActionPerformed
        abrirJIFUsuario();
    }//GEN-LAST:event_jmiUsuarioActionPerformed

    private void btnUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUsuarioActionPerformed
        abrirJIFUsuario();
    }//GEN-LAST:event_btnUsuarioActionPerformed

    private void jmiEmailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiEmailActionPerformed
        try {
            jDesktopPane.getSelectedFrame().setMaximum(rootPaneCheckingEnabled);
        } catch (PropertyVetoException ex) {
            Logger.getLogger(JFPrincipal.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jmiEmailActionPerformed

    private void jmiSobreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiSobreActionPerformed
        JOptionPane.showMessageDialog(null,
                "Sistema Gestor de Parque de Informática\n\n" +
                "Desenvolvido por : \n\n" +
                "Felipe Antonio \n" +
                "felipe.antonio.maria@gmail.com",
                "SIGEPI ver.: 1.0.0",
                JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_jmiSobreActionPerformed

    
    private void abrirJIFUsuario() {
        formUsuario = new JIFUsuario();
        if (jDesktopPane.getSelectedFrame() == null) {
            jDesktopPane.add(formUsuario);
                try {
                    formUsuario.setMaximum(rootPaneCheckingEnabled);
                }
                catch (PropertyVetoException ex) {
                    Logger.getLogger(Form.class.getName()).log(Level.SEVERE, null, ex);
                }               
        } 
        else {
            try{  
                if( jDesktopPane.getSelectedFrame().isIcon() )  
                    jDesktopPane.getSelectedFrame().setIcon(false);  
                }
            catch( PropertyVetoException pe ){  
                JOptionPane.showMessageDialog(rootPane, "Deu problema");
            }  
        }        
        formUsuario.setVisible(true);    
    }
    
    private void fecharAplicacao() {
        int n = JOptionPane.showConfirmDialog(rootPane,
                         "Deseja sair do sistema? ",
                         "Sair do sistema",
                         JOptionPane.YES_NO_OPTION);
        if (n == JOptionPane.YES_OPTION) {
            System.exit(0);            
        }        
    }
    
    
    /**
     * @param args the command line arguments
     */
    public static void iniciar() {
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new JFPrincipal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCertficado;
    private javax.swing.JButton btnChamado;
    private javax.swing.JButton btnConfiguracoes;
    private javax.swing.JButton btnContas;
    private javax.swing.JButton btnEmail;
    private javax.swing.JButton btnEstatisticas;
    private javax.swing.JButton btnHardware;
    private javax.swing.JButton btnPessoaFisica;
    private javax.swing.JButton btnPessoaJuridica;
    private javax.swing.JButton btnSair;
    private javax.swing.JButton btnServico;
    private javax.swing.JButton btnUsuario;
    private javax.swing.JDesktopPane jDesktopPane;
    private javax.swing.JMenu jmAjuda;
    private javax.swing.JMenu jmSistema;
    private javax.swing.JMenu jmTabelas;
    private javax.swing.JMenuBar jmbPrincipal;
    private javax.swing.JMenuItem jmiCertificado;
    private javax.swing.JMenuItem jmiConfiguracoes;
    private javax.swing.JMenuItem jmiEmail;
    private javax.swing.JMenuItem jmiPessoaFisica;
    private javax.swing.JMenuItem jmiPessoaJurídica;
    private javax.swing.JMenuItem jmiSair;
    private javax.swing.JMenuItem jmiSobre;
    private javax.swing.JMenuItem jmiUsuario;
    private javax.swing.JToolBar jtbInferior;
    private javax.swing.JToolBar jtbSuperior;
    private javax.swing.JLabel lblDatabasePath;
    private javax.swing.JLabel lblEspaco1;
    private javax.swing.JLabel lblEspaco2;
    private javax.swing.JLabel lblFrame;
    private javax.swing.JLabel lblUsuario;
    private javax.swing.JPanel pnlCentro;
    private javax.swing.JPanel pnlCentroLeste;
    private javax.swing.JPanel pnlCentroNorte;
    private javax.swing.JPanel pnlCentroOeste;
    private javax.swing.JPanel pnlCentroSul;
    // End of variables declaration//GEN-END:variables
}
